﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using ContractManagermentSystem.Business;
using ContractManagermentSystem.Entity;

namespace ContractManagermentSystem.Pages
{
    public partial class CreateRole : System.Web.UI.Page
    {
        private RoleBus _roleBus = new RoleBus();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void CreateRoleButton_Click(object sender, EventArgs e)
        {
            var role = new Role();
            role.RoleName = RoleNameTextBox.Text;
            role.Status = bool.Parse(StatusDropDownList.SelectedValue.ToString());
            int check = _roleBus.CheckRoleName(role.RoleName);
            if (check == 0)
            {
                _roleBus.CreateRole(role);
                MessageLabel.Visible = true;
                MessageLabel.Text = "Insert sucessful!";
            }
            else
            {
                MessageLabel.Visible = true;
                MessageLabel.Text = "RoleName Existed!";
            }
        }
    }
}
